import instance from "../utils/resqust";
import { productType } from "../types/product";

//新增产品
export const productPost = (obj:productType) => {
    return instance.post("classes/product", obj);
}


//查询所有产品
export const productGet = (page:number) => {
    let skip = 4 * (page - 1);
    return instance.get("classes/product", {
        params: {
            limit: 4,
            skip,
            count:1
        }
    });
}

//查询用户所有产品
export const userProductGet = (page: number) => {
    let skip = 10 * (page - 1);
    return instance.get("classes/product", {
          params: {
            limit: 10,
            skip,
            count:1
        }
    });
}

//修改产品
export const productPut = (objectId:any,obj:any) => {
    return instance.put(`classes/product/${objectId}`,obj);
}


//删除产品
export const productDel = (objectId:string) => {
    return instance.delete(`classes/product/${objectId}`);
}